"use strict";

/*
 * MikoPBX - free phone system for small business
 * Copyright © 2017-2023 Alexey Portnov and Nikolay Beketov
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program.
 * If not, see <https://www.gnu.org/licenses/>.
 */

/* global globalRootUrl, globalTranslate, Form, $, ClipboardJS */

/**
 * Object for handling provider management form
 *
 * @module provider
 */
var provider = {
  /**
   * jQuery object for the form.
   * @type {jQuery}
   */
  $formObj: $('#save-provider-form'),

  /**
   * jQuery object for the secret field.
   * @type {jQuery}
   */
  $secret: $('#secret'),
  $additionalHostsDummy: $('#additional-hosts-table .dummy'),
  providerType: $('#providerType').val(),
  $checkBoxes: $('#save-provider-form .checkbox'),
  $accordions: $('#save-provider-form .ui.accordion'),
  $dropDowns: $('#save-provider-form .ui.dropdown'),
  $deleteRowButton: $('#additional-hosts-table .delete-row-button'),
  $qualifyToggle: $('#qualify'),
  $qualifyFreqToggle: $('#qualify-freq'),
  $additionalHostInput: $('#additional-host input'),
  hostInputValidation: /^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(\d|[1-2]\d|3[0-2]))?|[a-zA-Z0-9-]{0,61}[a-zA-Z0-9](?:\.[a-zA-Z]{2,})+)$/gm,
  hostRow: '#save-provider-form .host-row',

  /**
   * Validation rules for the form fields before submission.
   *
   * @type {object}
   */
  validateRules: {
    description: {
      identifier: 'description',
      rules: [{
        type: 'empty',
        prompt: globalTranslate.pr_ValidationProviderNameIsEmpty
      }]
    },
    host: {
      identifier: 'host',
      rules: [{
        type: 'checkHostProvider',
        prompt: globalTranslate.pr_ValidationProviderHostIsEmpty
      }]
    },
    username: {
      identifier: 'username',
      optional: true,
      rules: [{
        type: 'minLength[2]',
        prompt: globalTranslate.pr_ValidationProviderLoginNotSingleSimbol
      }]
    },
    port: {
      identifier: 'port',
      rules: [{
        type: 'integer[1..65535]',
        prompt: globalTranslate.pr_ValidationProviderPortRange
      }]
    }
  },

  /**
   * Initialize the provider form.
   */
  initialize: function initialize() {
    provider.$checkBoxes.checkbox();
    provider.$accordions.accordion();
    provider.$dropDowns.dropdown();
    provider.updateHostsTableView();
    /**
     * Callback function called when the qualify toggle changes.
     */

    provider.$qualifyToggle.checkbox({
      onChange: function onChange() {
        if (provider.$qualifyToggle.checkbox('is checked')) {
          provider.$qualifyFreqToggle.removeClass('disabled');
        } else {
          provider.$qualifyFreqToggle.addClass('disabled');
        }
      }
    }); // Add new string to additional-hosts-table table

    provider.$additionalHostInput.keypress(function (e) {
      if (e.which === 13) {
        provider.cbOnCompleteHostAddress();
      }
    }); // Delete host from additional-hosts-table

    provider.$deleteRowButton.on('click', function (e) {
      e.preventDefault();
      $(e.target).closest('tr').remove();
      provider.updateHostsTableView();
      Form.dataChanged();
      return false;
    });
    provider.initializeForm();
    provider.updateVisibilityElements();
    $('#registration_type').on('change', provider.updateVisibilityElements);
    $('#disablefromuser input').on('change', provider.updateVisibilityElements);
    $('#generate-new-password').on('click', function (e) {
      /**
       * Event handler for the generate new password button click event.
       * @param {Event} e - The click event.
       */
      e.preventDefault();
      var chars = 'abcdef1234567890';
      var pass = '';

      for (var x = 0; x < 32; x += 1) {
        var i = Math.floor(Math.random() * chars.length);
        pass += chars.charAt(i);
      }

      provider.$secret.val(pass);
      provider.$secret.trigger('change');
    });
    provider.$secret.on('change', function () {
      $('#elSecret a.ui.button.clipboard').attr('data-clipboard-text', provider.$secret.val());
    });
    var clipboard = new ClipboardJS('.clipboard');
    $('.clipboard').popup({
      on: 'manual'
    });
    clipboard.on('success', function (e) {
      $(e.trigger).popup('show');
      setTimeout(function () {
        $(e.trigger).popup('hide');
      }, 1500);
      e.clearSelection();
    });
    clipboard.on('error', function (e) {
      console.error('Action:', e.action);
      console.error('Trigger:', e.trigger);
    });
  },

  /**
   * Update the visibility of elements based on the provider type and registration type.
   */
  updateVisibilityElements: function updateVisibilityElements() {
    if (provider.providerType !== 'SIP') {
      return;
    } // Get element references


    var elHost = $('#elHost');
    var elUsername = $('#elUsername');
    var elSecret = $('#elSecret');
    var elAdditionalHost = $('#elAdditionalHosts');
    var regType = $('#registration_type').val();
    var elUniqId = $('#uniqid');
    var genPassword = $('#generate-new-password');
    var valUserName = $('#username');
    var valSecret = provider.$secret; // Reset username if necessary

    if (valUserName.val() === elUniqId.val() && regType !== 'outbound') {
      valUserName.val('');
    }

    valUserName.removeAttr('readonly'); // Update element visibility based on registration type

    if (regType === 'outbound') {
      elHost.show();
      elUsername.show();
      elSecret.show();
      elAdditionalHost.show();
      genPassword.hide();
    } else if (regType === 'inbound') {
      valUserName.val(elUniqId.val());
      valUserName.attr('readonly', '');

      if (valSecret.val().trim() === '') {
        valSecret.val('id=' + $('#id').val() + '-' + elUniqId.val());
      }

      elHost.hide();
      elUsername.show();
      elSecret.show();
      genPassword.show();
    } else if (regType === 'none') {
      elHost.show();
      elUsername.hide();
      elSecret.hide();
    } // Update element visibility based on 'disablefromuser' checkbox


    var el = $('#disablefromuser');
    var fromUser = $('#divFromUser');

    if (el.checkbox('is checked')) {
      fromUser.hide();
      fromUser.removeClass('visible');
    } else {
      fromUser.show();
      fromUser.addClass('visible');
    }
  },

  /**
   * Callback function when completing the host address input.
   */
  cbOnCompleteHostAddress: function cbOnCompleteHostAddress() {
    var value = provider.$formObj.form('get value', 'additional-host');

    if (value) {
      var validation = value.match(provider.hostInputValidation); // Validate the input value

      if (validation === null || validation.length === 0) {
        provider.$additionalHostInput.transition('shake');
        return;
      } // Check if the host address already exists


      if ($(".host-row[data-value=\"".concat(value, "\"]")).length === 0) {
        var $tr = $('.host-row-tpl').last();
        var $clone = $tr.clone(true);
        $clone.removeClass('host-row-tpl').addClass('host-row').show();
        $clone.attr('data-value', value);
        $clone.find('.address').html(value);

        if ($(provider.hostRow).last().length === 0) {
          $tr.after($clone);
        } else {
          $(provider.hostRow).last().after($clone);
        }

        provider.updateHostsTableView();
        Form.dataChanged();
      }

      provider.$additionalHostInput.val('');
    }
  },

  /**
   * Updates the hosts table view based on the presence of additional hosts or shows dummy if there is no records
   */
  updateHostsTableView: function updateHostsTableView() {
    if ($(provider.hostRow).length === 0) {
      provider.$additionalHostsDummy.show();
    } else {
      provider.$additionalHostsDummy.hide();
    }
  },

  /**
   * Callback function to be called before the form is sent
   * @param {Object} settings - The current settings of the form
   * @returns {Object} - The updated settings of the form
   */
  cbBeforeSendForm: function cbBeforeSendForm(settings) {
    var result = settings;
    result.data = provider.$formObj.form('get values');
    var arrAdditionalHosts = [];
    $(provider.hostRow).each(function (index, obj) {
      if ($(obj).attr('data-value')) {
        arrAdditionalHosts.push({
          address: $(obj).attr('data-value')
        });
      }
    });
    result.data.additionalHosts = JSON.stringify(arrAdditionalHosts);
    return result;
  },

  /**
   * Callback function to be called after the form has been sent.
   * @param {Object} response - The response from the server after the form is sent
   */
  cbAfterSendForm: function cbAfterSendForm(response) {},

  /**
   * Initialize the form with custom settings
   */
  initializeForm: function initializeForm() {
    Form.$formObj = provider.$formObj;

    Form.$formObj.form.settings.rules.checkHostProvider = function (value) {
      var enable;

      if ($('#registration_type').val() === 'inbound') {
        enable = true;
      } else {
        enable = value.trim() !== '';
      }

      return enable;
    };

    switch (provider.providerType) {
      case 'SIP':
        Form.url = "".concat(globalRootUrl, "providers/save/sip"); // Form submission URL

        break;

      case 'IAX':
        Form.url = "".concat(globalRootUrl, "providers/save/iax"); // Form submission URL

        break;

      default:
        return;
    }

    Form.validateRules = provider.validateRules; // Form validation rules

    Form.cbBeforeSendForm = provider.cbBeforeSendForm; // Callback before form is sent

    Form.cbAfterSendForm = provider.cbAfterSendForm; // Callback after form is sent

    Form.initialize();
  }
};
/**
 * Custom form validation rule for username.
 * @param {string} noregister - The value of the 'noregister' attribute.
 * @param {string} username - The value of the username input field.
 * @returns {boolean} - Whether the validation rule passes or not.
 */

$.fn.form.settings.rules.username = function (noregister, username) {
  return !(username.length === 0 && noregister !== 'on');
};
/**
 *  Initialize provider management form on document ready
 */


$(document).ready(function () {
  provider.initialize();
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9Qcm92aWRlcnMvcHJvdmlkZXItbW9kaWZ5LmpzIl0sIm5hbWVzIjpbInByb3ZpZGVyIiwiJGZvcm1PYmoiLCIkIiwiJHNlY3JldCIsIiRhZGRpdGlvbmFsSG9zdHNEdW1teSIsInByb3ZpZGVyVHlwZSIsInZhbCIsIiRjaGVja0JveGVzIiwiJGFjY29yZGlvbnMiLCIkZHJvcERvd25zIiwiJGRlbGV0ZVJvd0J1dHRvbiIsIiRxdWFsaWZ5VG9nZ2xlIiwiJHF1YWxpZnlGcmVxVG9nZ2xlIiwiJGFkZGl0aW9uYWxIb3N0SW5wdXQiLCJob3N0SW5wdXRWYWxpZGF0aW9uIiwiaG9zdFJvdyIsInZhbGlkYXRlUnVsZXMiLCJkZXNjcmlwdGlvbiIsImlkZW50aWZpZXIiLCJydWxlcyIsInR5cGUiLCJwcm9tcHQiLCJnbG9iYWxUcmFuc2xhdGUiLCJwcl9WYWxpZGF0aW9uUHJvdmlkZXJOYW1lSXNFbXB0eSIsImhvc3QiLCJwcl9WYWxpZGF0aW9uUHJvdmlkZXJIb3N0SXNFbXB0eSIsInVzZXJuYW1lIiwib3B0aW9uYWwiLCJwcl9WYWxpZGF0aW9uUHJvdmlkZXJMb2dpbk5vdFNpbmdsZVNpbWJvbCIsInBvcnQiLCJwcl9WYWxpZGF0aW9uUHJvdmlkZXJQb3J0UmFuZ2UiLCJpbml0aWFsaXplIiwiY2hlY2tib3giLCJhY2NvcmRpb24iLCJkc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WxIb3N0SW5wdXQ6ICQoJyNhZGRpdGlvbmFsLWhvc3QgaW5wdXQnKSxcbiAgICBob3N0SW5wdXRWYWxpZGF0aW9uOiAvXigoKFswLTldfFsxLTldWzAtOV18MVswLTldezJ9fDJbMC00XVswLTldfDI1WzAtNV0pXFwuKXszfShbMC05XXxbMS05XVswLTldfDFbMC05XXsyfXwyWzAtNF1bMC05XXwyNVswLTVdKShcXC8oXFxkfFsxLTJdXFxkfDNbMC0yXSkpP3xbYS16QS1aMC05LV17MCw2MX1bYS16QS1aMC05XSg/OlxcLlthLXpBLVpdezIsfSkrKSQvZ20sXG4gICAgaG9zdFJvdzogJyNzYXZlLXByb3ZpZGVyLWZvcm0gLmhvc3Qtcm93JyxcblxuICAgIC8qKlxuICAgICAqIFZhbGlkYXRpb24gcnVsZXMgZm9yIHRoZSBmb3JtIGZpZWxkcyBiZWZvcmUgc3VibWlzc2lvbi5cbiAgICAgKlxuICAgICAqIEB0eXBlIHtvYmplY3R9XG4gICAgICovXG4gICAgdmFsaWRhdGVSdWxlczoge1xuICAgICAgICBkZXNjcmlwdGlvbjoge1xuICAgICAgICAgICAgaWRlbnRpZmllcjogJ2Rlc2NyaXB0aW9uJyxcbiAgICAgICAgICAgIHJ1bGVzOiBbXG4gICAgICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiAnZW1wdHknLFxuICAgICAgICAgICAgICAgICAgICBwcm9tcHQ6IGdsb2JhbFRyYW5zbGF0ZS5wcl9WYWxpZGF0aW9uUHJvdmlkZXJOYW1lSXNFbXB0eSxcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgXSxcbiAgICAgICAgfSxcbiAgICAgICAgaG9zdDoge1xuICAgICAgICAgICAgaWRlbnRpZmllcjogJ2hvc3QnLFxuICAgICAgICAgICAgcnVsZXM6IFtcbiAgICAgICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6ICdjaGVja0hvc3RQcm92aWRlcicsXG4gICAgICAgICAgICAgICAgICAgIHByb21wdDogZ2xvYmFsVHJhbnNsYXRlLnByX1ZhbGlkYXRpb25Qcm92aWRlckhvc3RJc0VtcHR5LFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBdLFxuICAgICAgICB9LFxuICAgICAgICB1c2VybmFtZToge1xuICAgICAgICAgICAgaWRlbnRpZmllcjogJ3VzZXJuYW1lJyxcbiAgICAgICAgICAgIG9wdGlvbmFsOiB0cnVlLFxuICAgICAgICAgICAgcnVsZXM6IFtcbiAgICAgICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6ICdtaW5MZW5ndGhbMl0nLFxuICAgICAgICAgICAgICAgICAgICBwcm9tcHQ6IGdsb2JhbFRyYW5zbGF0ZS5wcl9WYWxpZGF0aW9uUHJvdmlkZXJMb2dpbk5vdFNpbmdsZVNpbWJvbCxcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgXSxcbiAgICAgICAgfSxcbiAgICAgICAgcG9ydDoge1xuICAgICAgICAgICAgaWRlbnRpZmllcjogJ3BvcnQnLFxuICAgICAgICAgICAgcnVsZXM6IFtcbiAgICAgICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6ICdpbnRlZ2VyWzEuLjY1NTM1XScsXG4gICAgICAgICAgICAgICAgICAgIHByb21wdDogZ2xvYmFsVHJhbnNsYXRlLnByX1ZhbGlkYXRpb25Qcm92aWRlclBvcnRSYW5nZSxcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgXSxcbiAgICAgICAgfSxcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogSW5pdGlhbGl6ZSB0aGUgcHJvdmlkZXIgZm9ybS5cbiAgICAgKi9cbiAgICBpbml0aWFsaXplKCkge1xuICAgICAgICBwcm92aWRlci4kY2hlY2tCb3hlcy5jaGVja2JveCgpO1xuICAgICAgICBwcm92aWRlci4kYWNjb3JkaW9ucy5hY2NvcmRpb24oKTtcbiAgICAgICAgcHJvdmlkZXIuJGRyb3BEb3ducy5kcm9wZG93bigpO1xuICAgICAgICBwcm92aWRlci51cGRhdGVIb3N0c1RhYmxlVmlldygpO1xuICAgICAgICAvKipcbiAgICAgICAgICogQ2FsbGJhY2sgZnVuY3Rpb24gY2FsbGVkIHdoZW4gdGhlIHF1YWxpZnkgdG9nZ2xlIGNoYW5nZXMuXG4gICAgICAgICAqL1xuICAgICAgICBwcm92aWRlci4kcXVhbGlmeVRvZ2dsZS5jaGVja2JveCh7XG4gICAgICAgICAgICBvbkNoYW5nZSgpIHtcbiAgICAgICAgICAgICAgICBpZiAocHJvdmlkZXIuJHF1YWxpZnlUb2dnbGUuY2hlY2tib3goJ2lzIGNoZWNrZWQnKSkge1xuICAgICAgICAgICAgICAgICAgICBwcm92aWRlci4kcXVhbGlmeUZyZXFUb2dnbGUucmVtb3ZlQ2xhc3MoJ2Rpc2FibGVkJyk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcHJvdmlkZXIuJHF1YWxpZnlGcmVxVG9nZ2xlLmFkZENsYXNzKCdkaXNhYmxlZCcpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgIH0pO1xuXG4gICAgICAgIC8vIEFkZCBuZXcgc3RyaW5nIHRvIGFkZGl0aW9uYWwtaG9zdHMtdGFibGUgdGFibGVcbiAgICAgICAgcHJvdmlkZXIuJGFkZGl0aW9uYWxIb3N0SW5wdXQua2V5cHJlc3MoKGUpID0+IHtcbiAgICAgICAgICAgIGlmIChlLndoaWNoID09PSAxMykge1xuICAgICAgICAgICAgICAgIHByb3ZpZGVyLmNiT25Db21wbGV0ZUhvc3RBZGRyZXNzKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIC8vIERlbGV0ZSBob3N0IGZyb20gYWRkaXRpb25hbC1ob3N0cy10YWJsZVxuICAgICAgICBwcm92aWRlci4kZGVsZX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ZvciAobGV0IHggPSAwOyB4IDwgMzI7IHggKz0gMSkge1xuICAgICAgICAgICAgICAgIGNvbnN0IGkgPSBNYXRoLmZsb29yKE1hdGgucmFuZG9tKCkgKiBjaGFycy5sZW5ndGgpO1xuICAgICAgICAgICAgICAgIHBhc3MgKz0gY2hhcnMuY2hhckF0KGkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcHJvdmlkZXIuJHNlY3JldC52YWwocGFzcyk7XG4gICAgICAgICAgICBwcm92aWRlci4kc2VjcmV0LnRyaWdnZXIoJ2NoYW5nZScpO1xuICAgICAgICB9KTtcblxuICAgICAgICBwcm92aWRlci4kc2VjcmV0Lm9uKCdjaGFuZ2UnLCAoKSA9PiB7XG4gICAgICAgICAgICAkKCcjZWxTZWNyZXQgYS51aS5idXR0b24uY2xpcGJvYXJkJykuYXR0cignZGF0YS1jbGlwYm9hcmQtdGV4dCcsIHByb3ZpZGVyLiRzZWNyZXQudmFsKCkpXG4gICAgICAgIH0pO1xuXG4gICAgICAgIGNvbnN0IGNsaXBib2FyZCA9IG5ldyBDbGlwYm9hcmRKUygnLmNsaXBib2FyZCcpO1xuICAgICAgICAkKCcuY2xpcGJvYXJkJykucG9wdXAoe1xuICAgICAgICAgICAgb246ICdtYW51YWwnLFxuICAgICAgICB9KTtcblxuICAgICAgICBjbGlwYm9hcmQub24oJ3N1Y2Nlc3MnLCAoZSkgPT4ge1xuICAgICAgICAgICAgJChlLnRyaWdnZXIpLnBvcHVwKCdzaG93Jyk7XG4gICAgICAgICAgICBzZXRUaW1lb3V0KCgpID0+IHtcbiAgICAgICAgICAgICAgICAkKGUudHJpZ2dlcikucG9wdXAoJ2hpZGUnKTtcbiAgICAgICAgICAgIH0sIDE1MDApO1xuICAgICAgICAgICAgZS5jbGVhclNlbGVjdGlvbigpO1xuICAgICAgICB9KTtcblxuICAgICAgICBjbGlwYm9hcmQub24oJ2Vycm9yJywgKGUpID0+IHtcbiAgICAgICAgICAgIGNvbnNvbGUuZXJy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eVxuICAgICAgICBpZiAodmFsVXNlck5hbWUudmFsKCkgPT09IGVsVW5pcUlkLnZhbCgpICYmIHJlZ1R5cGUgIT09ICdvdXRib3VuZCcpIHtcbiAgICAgICAgICAgIHZhbFVzZXJOYW1lLnZhbCgnJyk7XG4gICAgICAgIH1cbiAgICAgICAgdmFsVXNlck5hbWUucmVtb3ZlQXR0cigncmVhZG9ubHknKTtcblxuICAgICAgICAvLyBVcGRhdGUgZWxlbWVudCB2aXNpYmlsaXR5IGJhc2VkIG9uIHJlZ2lzdHJhdGlvbiB0eXBlXG4gICAgICAgIGlmIChyZWdUeXBlID09PSAnb3V0Ym91bmQnKSB7XG4gICAgICAgICAgICBlbEhvc3Quc2hvdygpO1xuICAgICAgICAgICAgZWxVc2VybmFtZS5zaG93KCk7XG4gICAgICAgICAgICBlbFNlY3JldC5zaG93KCk7XG4gICAgICAgICAgICBlbEFkZGl0aW9uYWxIb3N0LnNob3coKTtcbiAgICAgICAgICAgIGdlblBhc3N3b3JkLmhpZGUoKTtcbiAgICAgICAgfSBlbHNlIGlmIChyZWdUeXBlID09PSAnaW5ib3VuZCcpIHtcbiAgICAgICAgICAgIHZhbFVzZXJOYW1lLnZhbChlbFVuaXFJZC52YWwoKSk7XG4gICAgICAgICAgICB2YWxVc2VyTmFtZS5hdHRyKCdyZWFkb25seScsICcnKTtcbiAgICAgICAgICAgIGlmICh2YWxTZWNyZXQudmFsKCkudHJpbSgpID09PSAnJykge1xuICAgICAgICAgICAgICAgIHZhbFNlY3JldC52YWwoJ2lkPScgKyAkKCcjaWQnKS52YWwoKSArICctJyArIGVsVW5pcUlkLnZhbCgpKVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxIb3N0LmhpZGUoKTtcbiAgICAgICAgICAgIGVsVXNlcm5hbWUuc2hvdygpO1xuICAgICAgICAgICAgZWxTZWNyZXQuc2hvdygpO1xuICAgICAgICAgICAgZ2VuUGFzc3dvcmQuc2hvdygpO1xuICAgICAgICB9IGVsc2Ug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kYXRlIHRoZSBpbnB1dCB2YWx1ZVxuICAgICAgICAgICAgaWYgKHZhbGlkYXRpb24gPT09IG51bGxcbiAgICAgICAgICAgICAgICB8fCB2YWxpZGF0aW9uLmxlbmd0aCA9PT0gMCkge1xuICAgICAgICAgICAgICAgIHByb3ZpZGVyLiRhZGRpdGlvbmFsSG9zdElucHV0LnRyYW5zaXRpb24oJ3NoYWtlJyk7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBDaGVjayBpZiB0aGUgaG9zdCBhZGRyZXNzIGFscmVhZHkgZXhpc3RzXG4gICAgICAgICAgICBpZiAoJChgLmhvc3Qtcm93W2RhdGEtdmFsdWU9XCIke3ZhbHVlfVwiXWApLmxlbmd0aCA9PT0gMCkge1xuICAgICAgICAgICAgICAgIGNvbnN0ICR0ciA9ICQoJy5ob3N0LXJvdy10cGwnKS5sYXN0KCk7XG4gICAgICAgICAgICAgICAgY29uc3QgJGNsb25lID0gJHRyLmNsb25lKHRydWUpO1xuICAgICAgICAgICAgICAgICRjbG9uZVxuICAgICAgICAgICAgICAgICAgICAucmVtb3ZlQ2xhc3MoJ2hvc3Qtcm93LXRwbCcpXG4gICAgICAgICAgICAgICAgICAgIC5hZGRDbGFzcygnaG9zdC1yb3cnKVxuICAgICAgICAgICAgICAgICAgICAuc2hvdygpO1xuICAgICAgICAgICAgICAgICRjbG9uZS5hdHRyKCdkYXRhLXZhbHVlJywgdmFsdWUpO1xuICAgICAgICAgICAgICAgICRjbG9uZS5maW5kKCcuYWRkcmVzcycpLmh0bWwodmFsdWUpO1xuICAgICAgICAgICAgICAgIGlmICgkKHByb3ZpZGVyLmhvc3RSb3cpLmxhc3QoKS5sZW5ndGggPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgJHRyLmFmdGVyKCRjbG9uZSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgJChwcm92aWRlci5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